package day20171115;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * Created by Administrator on 2017-11-15.
 */
public class Test {


    public static void main(String[] args) {


        // 读文件


        //1.字符流
        //1.1 一次读一行（多个）
        // BufferedReader, FileReader
        BufferedReader bufferedReader = null;
        try {
             bufferedReader =
                    new BufferedReader(
                            new FileReader("E:\\hello.txt"));

//            String line = "";
//
//            while ((line = bufferedReader.readLine()) != null) {
//                System.out.println(line);
//            }

            int tmp;
            while((tmp = bufferedReader.read()) != -1){

                System.out.println((char) tmp);
            }


//            line = bufferedReader.readLine();
//            System.out.println(line);
//
//            line = bufferedReader.readLine();
//            System.out.println(line);
//
//            line = bufferedReader.readLine();
//            System.out.println(line);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {

            try {
                bufferedReader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }


        //2. 字节流


    }


}
